In
data hierarchy, a field (data field) is a
variable in a
record.
A record, also known as a
data structure
In computer science, a data structure is a data organization and storage format that is usually chosen for Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the relationships amo ...
, allows logically related data to be identified by a single name. Identifying related data as a single group is central to the construction of understandable
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
s.
The individual fields in a record may be accessed by name, just like any variable in a computer program.
Each field in a record has two components. One component is the field's
datatype declaration. The other component is the field's
identifier.
Memory fields
Fields may be stored in
random access memory (RAM). The following
Pascal record definition has three field identifiers: firstName, lastName, and age. The two name fields have a datatype of an
array of
character. The age field has a datatype of
integer.
type PersonRecord =
record
lastName : array 1 .. 20 of Char;
firstName : array 1 .. 20 of Char;
age : Integer
end;
In Pascal, the identifier component precedes a colon, and the datatype component follows the colon. Once a record is defined,
variables of the record can be
allocated. Once the memory of the record is allocated, a field can be accessed like a variable by using the dot notation.
var alice : PersonRecord;
alice.firstName := 'Alice';
The term ''field'' has been replaced with the terms ''data member''
and ''attribute''.
The following
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
class has three attributes: firstName, lastName, and age.
public class PersonRecord
File fields

Fields may be stored in a
random access file.
A file may be written to or read from in an arbitrary order. To accomplish the arbitrary access, the
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
provides a method to quickly ''seek'' around the file.
Once the
disk head is positioned at the beginning of a record, each file field can be read into its corresponding memory field.
File fields are the main storage structure in the
Indexed Sequential Access Method (ISAM). In
relational database theory, the term ''field'' has been replaced with the terms ''column'' and ''attribute''.
See also
*
*
References
{{DEFAULTSORT:Field (Computer Science)
Data modeling